package mutsumimod.actions;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.vfx.combat.FlashAtkImgEffect;

public class MutsumiKickAction extends AbstractGameAction {
    private final AbstractMonster target;
    private final DamageInfo info;
    private final int damageTarget;

    public MutsumiKickAction(AbstractMonster target, DamageInfo info, int damageTarget) {
        this.target = target;
        this.info = info;
        this.damageTarget = damageTarget;
        this.duration = Settings.ACTION_DUR_FAST;
    }

    public void update() {
        if (!this.isDone) {
            AbstractDungeon.effectList.add(new FlashAtkImgEffect(this.target.hb.cX, this.target.hb.cY,
                    AbstractGameAction.AttackEffect.BLUNT_HEAVY, false));
            this.target.damage(this.info);
            this.addToBot(new TriggerStandAction(5, new AdditionalAction(this.target.lastDamageTaken, this.damageTarget)));
            this.isDone = true;
        }
        tickDuration();

    }

    /**
     * 因为感觉这个Action没什么其他用处所以用的内部类
     */
    public class AdditionalAction extends AbstractGameAction {
        private final int damage;
        private final int target;

        public AdditionalAction(int damage, int target) {
            this.damage = damage;
            this.target = target;
            this.actionType = ActionType.BLOCK;
        }

        public void update() {
            if (!this.isDone) {
                if (this.damage >= this.target) {
                    this.addToBot(new DrawCardAction(AbstractDungeon.player, 1));
                    this.addToBot(new GainEnergyAction(1));
                }
                this.isDone = true;
            }
            tickDuration();
        }

    }

}
